<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <title>{$footcompany.web_site_title}</title>
    <meta name="keywords" content="{$footcompany.web_site_keyword}">
    <meta name="description" content="{$footcompany.web_site_description}">
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <link rel="stylesheet" href="/static/index/css/plugins-2.2.css">
    <link rel="stylesheet" href="/static/index/css/theme-2.2.css">
    <link rel="stylesheet" href="/static/index/css/iconfont.css">
    <link rel="stylesheet" href="/static/index/css/swiper.min.css">
    <link rel="stylesheet" href="/static/index/css/main.min.css">
    <link rel="stylesheet" href="/static/index/css/frontend.min.css">
    <link href="{$footcompany.web_site_ico}" type="image/x-icon" rel="shortcut icon" />
    <script src="/static/index/js/jquery.min1.js"></script>
    <!--新增逻辑-->
    <!-- <script src="/static/index/js/main.js"></script> -->
</head>
<style>
    #toast-container {
        display: none;
        top:70px;
        position: fixed;
        z-index: 999999;
        pointer-events: none;
        text-align: center;
    }
    .green {
        border-color: #18bc9c !important;
        box-shadow: none;
    }
    .text-green{
        color:#18bc9c !important;
    }
    .red{
        border-color: #e74c3c !important;
        box-shadow: none;
    }
    .text-red{
        color:#e74c3c !important;
    }
    .n-icon {
        background-image: url(/static/index/picture/validator_default.png);
    }
</style>
<body>
{include file="../application/index/view/common/header.html" /}
<div id="content-container" class="container">
    <div class="user-section login-section">
        <div class="logon-tab clearfix">
            {if condition="$register.value eq '1'"}
            <a class="active">登 录</a> 
            <a href="/user/register">注 册</a>
            {/if}
            </div>
        <div class="login-main">
            <form id="form1" onsubmit="return false" action="##" method="post">
                <!-- <input type="hidden" name="url" value=""> -->
                <!-- <input type="hidden" name="__token__" value="fee5e27df6d7f9bb88fe467425145037">                 -->
                <div class="form-group">
                    <div>
                        <label class="control-label" for="account" id="text-account">账号</label>
                        <label class="control-label required" style="float:right;color:#c33;display: none" id="account-msg"><span class="text-success"></span></label>
                    </div>
                    <div class="controls">
                        <input class="form-control input-lg" id="account" type="text" name="account" value="" placeholder="用户名/手机" autocomplete="off">
                        <div class="help-block"></div>
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label" for="password" id="text-password">密码</label>
                    <label class="control-label required" style="float:right;color:#c33;display: none" id="password-msg"><span class="text-success"></span></label>
                    <div class="controls">
                        <input class="form-control input-lg" id="password" type="password" name="password" placeholder="密码" autocomplete="off">
                    </div>
                </div>
                <div class="form-group">
                    <div class="controls">
                        <input type="checkbox" name="keeplogin" checked="checked" value="1"> 保持会话                        
                        <div class="pull-right">
                            <a href="/my/forgetpwd" class="btn-forgot">忘记密码?</a>
                        </div>
                    </div>
                </div>
                <label class="tishi" id="tishi-account" style="float:right;margin-top:5px;height:20px;"></label>
                <div class="form-group">
                    <button type="button" onclick="login()" class="btn btn-primary btn-md btn-block">登 录</button>
                </div>
            </form>
            <div class="row">
                <div class="col-xs-12 col-sm-6">
                    <!-- <a href="javascript:" data-url="" data-time="" data-sig="" class="btn btn-block btn-default mb-1 btn-wechat">
                        <i class="fa fa-wechat text-green"></i> 使用微信扫码登录
                    </a> -->
                </div>
                
            </div>
        </div>
    </div>
</div>
<!--为空提示框 -->
<div id="toast-container" class="toast-top-center">
<div class="toast toast-error" aria-live="assertive" >
    <!-- <button type="button" class="toast-close-button" role="button">×</button> -->
    <div class="toast-message"></div>
</div>
</div>

<div class="layui-layer layui-layer-dialog layui-layer-border layui-layer-fast layui-layer-fast-msg layui-layer-hui" id="parent-msg" style="z-index: 19891021; top: 251.5px; left: 884.5px;display: none;">
    <div id="msg" class="layui-layer-content">错误</div>
</div>
<!-- 底部 -->
{include file="../application/index/view/common/foot.html" /}
<script>
    //账号
    $("#account").focusin(function(){
        if($(this).val() != ""){
            $(this).removeClass("red");
            $(this).addClass("green");
        }else{
            $(this).removeClass("green")
            $(this).addClass("red");
        }
    })
    $("#account").focusout(function(){
        if($(this).val() != ""){ 
            $('#account-msg').css('display','none');
            $(this).removeClass("red");
            $(this).addClass("green");
        }else{
            $('#account-msg').text('账号不能为空');
            $('#account-msg').css('display','block');
            $(this).removeClass("green");
            $(this).addClass("red");
        }
    })
    //密码
    $("#password").focusin(function(){
        if($(this).val() != ""){
            $(this).removeClass("red");
            $(this).addClass("green");
        }else{
            $(this).removeClass("green")
            $(this).addClass("red");
        }
    })
    $("#password").focusout(function(){
        if($(this).val() != ""){ 
            $('#password-msg').css('display','none');
            $(this).removeClass("red");
            $(this).addClass("green");
        }else{
            $('#password-msg').text('密码不能为空');
            $('#password-msg').css('display','block');
            $(this).removeClass("green");
            $(this).addClass("red");
        }
    })

function login(){
    var account = $("#account").val();
    var password = $("#password").val();
    if(account == ""){
        $("#toast-container").show().delay(1000).hide(300);
        $(".toast-message").text('账号不能为空');
        return false;
    }
    if(password == ""){
        $("#toast-container").show().delay(1000).hide(300);
        $(".toast-message").text('密码不能为空');
        return false;
    }

    $.ajax({
        //几个参数需要注意一下
        type: "POST",//方法类型
        url: "/user/loging" ,//url
        data: $('#form1').serialize(),
        success: function (result) {
            if (result.code == 200) {
                window.location.href = '/index';
            }else{
                $("#parent-msg").show().delay(1000).hide(300);
                $("#msg").text(result.msg);
            }
        },
        error : function() {
            $("#parent-msg").show().delay(1000).hide(300);
            $("#msg").text('系统错误，请重试！');
        }
    });
}
</script>
</div>
</body>
</html>